<template>
	<view>
		<view class="title bk-white pd-xl mg-b-xl">{{raceName}}</view>
		
		<view :class="item.class" v-for="(item, index) in buttons" :key="index">
			<view class="hspace-xl" />
			<view class="bk-white radius flex1 lay-c-c pd-md" @click="onTapBtn(item.name1, item.url1)">
				<image class="logo" :src="item.logo1"></image>
				<view class="mg-l-xl">{{item.name1}}</view>
			</view>
			<view class="hspace-xl" />
			<view class="bk-white radius flex1 lay-c-c pd-md" @click="onTapBtn(item.name2, item.url2)">
				<image class="logo" :src="item.logo2"></image>
				<view class="mg-l-xl">{{item.name2}}</view>
			</view>
			<view class="hspace-xl" />
		</view>
		
	</view>
</template>

<script>
	import { Modal } from '../../libs/uniApi.js';
	import {MyTip} from '../../components/ssty/common.js';
	import {softDeleteRace, resetRace} from '@/api/fsh.js'
	
	export default {
		data() {
			return {
				raceName: '',
				buttons: [{
					class: "lay-c-c mg-b-lg",
					logo1: 'https://mer.chuidiaotop.com/static/images/race/%E6%AF%94%E8%B5%9B%E8%AE%BE%E7%BD%AE.png',
					name1: '场次设置',
					url1: `/pages/fsh_race/race_manage_edit_round?raceId=`,
					
					logo2: 'https://mer.chuidiaotop.com/static/images/race/%E6%8A%BD%E7%AD%BE%E8%AE%BE%E7%BD%AE.png',
					name2: '抽签设置',
					url2: `/pages/fsh_race/race_manage_edit_draw_lots?raceId=`,
				},{
					class: "lay-c-c mg-b-lg marginTop",
					logo1: 'https://mer.chuidiaotop.com/static/images/race/%E6%8A%A5%E5%90%8D%E5%90%8D%E5%8D%95.png',
					name1: '报名名单',
					url1: `/pages/fsh_race/race_manage_sign_up?raceId=`,
					
					logo2: 'https://mer.chuidiaotop.com/static/images/race/%E6%AF%94%E8%B5%9B%E8%AE%BE%E7%BD%AE.png',
					name2: '签到管理',
					url2: `/pages/fsh_race/race_manage_sign_in?raceId=`,
				},{
					class: "lay-c-c mg-b-lg marginTop",
					logo1: 'https://mer.chuidiaotop.com/static/images/race/%E6%8A%BD%E7%AD%BE%E8%AE%BE%E7%BD%AE.png',
					name1: '抽签管理',
					url1: `/pages/fsh_race/race_manage_edit_draw_lots_list?raceId=`,
					
					logo2: 'https://mer.chuidiaotop.com/static/images/race/%E8%B5%9B%E4%BA%8B%E7%BC%96%E8%BE%91.png',
					name2: '赛事编辑',
					url2: `/pages/fsh_race/race_manage_edit_info?scene=2&raceId=`,
				},{
					class: "lay-c-c mg-b-lg",
					logo1: 'https://mer.chuidiaotop.com/static/images/race/%E6%88%90%E7%BB%A9%E5%BD%95%E5%85%A5.png',
					name1: '成绩录入',
					url1: `/pages/fsh_race/race_score?for_raceMangeEditScore=1&raceId=`,
					
					logo2: 'https://mer.chuidiaotop.com/static/images/race/%E6%88%90%E7%BB%A9%E5%BD%95%E5%85%A5.png',
					name2: '查看成绩',
					url2: `/pages/fsh_race/race_score?raceId=`,
				},{
					class: "lay-c-c mg-b-lg marginTop",
					logo1: 'https://mer.chuidiaotop.com/static/images/race/%E9%87%8D%E6%96%B0%E5%8F%91%E5%B8%83.png',
					name1: '重新发布',
					url1: `/pages/fsh_race/race_manage_edit_info?scene=3&raceId=`,
					
					logo2: 'https://mer.chuidiaotop.com/static/images/race/%E8%B5%9B%E4%BA%8B%E6%8A%BD%E5%A5%96.png',
					name2: '重置比赛(报名和签到不会丢)',
					url2: ``,
					
					// logo2: 'https://mer.chuidiaotop.com/static/images/race/%E8%B5%9B%E4%BA%8B%E6%8A%BD%E5%A5%96.png',
					// name2: '赛事抽奖',
					// url2: `/pages/fsh_race/race_manage_luck_draw?raceId=`,
				},{
					class: "lay-c-c mg-b-lg",
					logo1: 'https://mer.chuidiaotop.com/static/images/race/%E8%B5%9B%E4%BA%8B%E6%8A%BD%E5%A5%96.png',
					name1: '分享比赛',
					url1: `/pages/fsh_race/race_share?raceId=`,
					
					logo2: 'https://mer.chuidiaotop.com/static/images/race/%E5%88%A0%E9%99%A4%E6%AF%94%E8%B5%9B.png',
					name2: '删除比赛',
					url2: ``,
					
				}]
			}
		},
		onLoad(options) {
			this.raceId = options.raceId;
			this.merId = options.merId;
			this.raceName = options.raceName;
			this.prodId = options.prodId;
		},
		methods: {
			onTapBtn(name, url) {
				if(name == '删除比赛') {
					Modal('提示', '确认要删除当前比赛吗？').then(res=>{
						softDeleteRace(this.raceId, this.prodId)
						.then(res=>{
							uni.navigateBack()
						})
						.catch(err=>{})
					})
				} else if(name.indexOf('重置比赛') >= 0) {
					Modal('提示', '确认要重置当前比赛吗？').then(res=>{
						resetRace(this.raceId, this.prodId)
						.then(res=>{
							console.log("reset",res)
							MyTip("重置成功")
						})
						.catch(err=>{
							MyTip("重置失败")
						})
					})
				} else {
					uni.navigateTo({
						url: url+this.raceId+"&prodId="+this.prodId+"&merId="+this.merId
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/leui.scss";
	
	page {
		height: 100%;
		background-color: #f5f5f5;
	}
	
	.marginTop {
		margin-top: 70px;
	}
</style>
